package com.luxk.dbt;

public class ExecFactory {

	public static AbstractExec factory(String type, String name, ExecIF parent,
			MainContext mCtx) throws DBTException {
		
		if("case".equalsIgnoreCase(type))
			return new ExecBlockCase(name, parent, mCtx);
		
		if("prework".equalsIgnoreCase(type))
			return new ExecBlockPrework(name, parent, mCtx);
		
		if("postwork".equalsIgnoreCase(type))
			return new ExecBlockPostwork(name, parent, mCtx);
		
		if("performance_test".equalsIgnoreCase(type))
			return new ExecBlockPerformanceTest(name, parent, mCtx);

		if("functional_test".equalsIgnoreCase(type))
			return new ExecBlockFunctionalTest(name, parent, mCtx);

		if("session".equalsIgnoreCase(type))
			return new ExecBlockSession(name, parent, mCtx);

		if("transaction".equalsIgnoreCase(type))
			return new ExecBlockTransaction(name, parent, mCtx);

		if("expr".equalsIgnoreCase(type))
			return new ExecLineExpr(name, parent, mCtx);
		
		if("loop".equalsIgnoreCase(type))
			return new ExecBlockLoop(name, parent, mCtx);
		
		if("sql_exec".equalsIgnoreCase(type))
			return new ExecBlockSQLExec(name, parent, mCtx);
		
		if("sql_select".equalsIgnoreCase(type))
			return new ExecBlockSQLSelect(name, parent, mCtx);
		
		if("sql_commit".equalsIgnoreCase(type))
			return new ExecLineSQLCommit(name, parent, mCtx);
		
		if("sql_rollback".equalsIgnoreCase(type))
			return new ExecLineSQLRollback(name, parent, mCtx);
		
		if("expect".equalsIgnoreCase(type))
			return new ExecLineExpect(name, parent, mCtx);
		
		if("command".equalsIgnoreCase(type))
			return new ExecLineCommand(name, parent, mCtx);
		
		if("wait".equalsIgnoreCase(type))
			return new ExecLineWait(name, parent, mCtx);
		
		if("notify".equalsIgnoreCase(type))
			return new ExecLineNotify(name, parent, mCtx);
		
		if("sleep".equalsIgnoreCase(type))
			return new ExecLineSleep(name, parent, mCtx);

		if("external_class".equalsIgnoreCase(type))
			return new ExecLineExternalClass(name, parent, mCtx);
		
		if("thread".equalsIgnoreCase(type))
			return new ExecBlockThread(name, parent, mCtx);

		if("threads".equalsIgnoreCase(type))
			return new ExecBlockThreads(name, parent, mCtx);

		throw new DBTException("Invalid processing type " + type);
	}
	
	public static boolean isExec(String str) {
		
		if("case".equalsIgnoreCase(str))
			return true;
		
		if("prework".equalsIgnoreCase(str))
			return true;
		
		if("postwork".equalsIgnoreCase(str))
			return true;
		
		if("performance_test".equalsIgnoreCase(str))
			return true;
		
		if("functional_test".equalsIgnoreCase(str))
			return true;
		
		if("session".equalsIgnoreCase(str))
			return true;

		if("transaction".equalsIgnoreCase(str))
			return true;

		if("expr".equalsIgnoreCase(str))
			return true;
		
		if("loop".equalsIgnoreCase(str))
			return true;
		
		if("sql_exec".equalsIgnoreCase(str))
			return true;
		
		if("sql_select".equalsIgnoreCase(str))
			return true;
		
		if("sql_commit".equalsIgnoreCase(str))
			return true;
		
		if("sql_rollback".equalsIgnoreCase(str))
			return true;
		
		if("expect".equalsIgnoreCase(str))
			return true;
		
		if("command".equalsIgnoreCase(str))
			return true;
		
		if("wait".equalsIgnoreCase(str))
			return true;
		
		if("notify".equalsIgnoreCase(str))
			return true;
		
		if("sleep".equalsIgnoreCase(str))
			return true;
		
		if("external_class".equalsIgnoreCase(str))
			return true;

		if("thread".equalsIgnoreCase(str))
			return true;

		if("threads".equalsIgnoreCase(str))
			return true;

		return false;
	}
}
